<?php
if (isset($_POST['o']) &&  !empty($_POST['o']) ){
    include 'load.php';
    $openid=$_POST['o'];
    $mysqli = new mysqli($dbhost, $dbuser, $dbpwd, $dbName);
    if (!$mysqli->set_charset("utf8")) {}
    $isold='new';
    $dizhi='';
    $queren='';
    $query=$mysqli->query("SELECT sheng,shi,dizhi,isold,queren FROM `uinfo` where openid='".$openid."' limit 0,1 ");
    if($query->num_rows>0){
        $uinfo=$query->fetch_array();
        $isold=$uinfo['isold'];
        $dizhi=$uinfo['sheng'].$uinfo['shi'].$uinfo['dizhi'];
        $queren=$uinfo['queren'];
    }
    
    $a=$b=$c='';
    $query=$mysqli->query("SELECT avatar FROM `users` where openid='".$openid."' limit 0,1 ");
    if($query->num_rows>0){
        $getUsers=$query->fetch_array(); 
        $a=array('a'=>$getUsers['avatar']);
        
    }
    $getshare=array();
    $getRealShare=array();
    $query=$mysqli->query("SELECT zuopenid FROM `share` where openid='".$openid."' limit 0,4 ");
    if($query->num_rows>0){
        $theCon=NULL;
        $condition=array();
        while ($list = $query->fetch_array()){
            $condition[]=" openid='".$list['zuopenid']."' ";
        }
        if (!empty($condition)){
            $theCon=implode(' or ', $condition);
        }
        if (empty($theCon)){
            echo json_encode(array('msg'=>'no'));
            exit;
        }
        
        $queryU=$mysqli->query("SELECT openid,avatar FROM `users` where ".$theCon." limit 0,3 ");
        
        while ($list=$queryU->fetch_array()){
            $getshare[]=array('a'=>$list['avatar']);
            $getRealShare[$list['openid']]=array('a'=>$list['avatar']);
        }
        if (isset($getshare[0])){
            $b=array('a'=>$getshare[0]['a']);
        }
        if (isset($getshare[1]) && count($condition) > 1){
            $c=array('a'=>$getshare[1]['a']);
        }
        
    }
    
    echo json_encode(array('msg'=>'h','A'=>$a,'B'=>$b,'C'=>$c,'num'=>count($getRealShare),'isold'=>$isold,'dizhi'=>$dizhi,'queren'=>$queren));
     
    $mysqli->close();
}